home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / bootlogd < prev    next >
Text File  |  2008-10-14  |  2KB  |  96 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          bootlogd
  4. # Required-Start:    mountdevsubfs
  5. # Required-Stop:
  6. # Default-Start:     S
  7. # Default-Stop:
  8. # Short-Description: Start or stop bootlogd.
  9. # Description:       Starts or stops the bootlogd log program
  10. #                    which logs boot messages.
  11. ### END INIT INFO
  12.  
  13. PATH=/sbin:/bin  # No remote fs at start
  14. DAEMON=/sbin/bootlogd
  15. [ -x "$DAEMON" ] || exit 0
  16. NAME=bootlogd
  17. DESC="boot logger"
  18. BOOTLOGD_OPTS="-r -c"
  19. [ -r /etc/default/bootlogd ] && . /etc/default/bootlogd
  20. . /lib/init/vars.sh
  21.  
  22. . /lib/lsb/init-functions
  23.  
  24. # Because bootlogd is broken on some systems, we take the special measure
  25. # of requiring it to be enabled by setting an environment variable.
  26. case "$BOOTLOGD_ENABLE" in
  27.   [Nn]*)
  28.     exit 0
  29.     ;;
  30. esac
  31.  
  32. # Previously this script was symlinked as "stop-bootlogd" which, when run
  33. # with the "start" argument, should stop bootlogd.  Now stop-bootlogd is
  34. # a distinct script, but for backward compatibility this script continues
  35. # to implement the old behavior.
  36. SCRIPTNAME=${0##*/}
  37. SCRIPTNAME=${SCRIPTNAME#[SK]??}
  38. ACTION="$1"
  39. case "$0" in
  40.   *stop-bootlog*)
  41.     [ "$ACTION" = start ] && ACTION=stop
  42.     ;;
  43. esac
  44.  
  45. case "$ACTION" in
  46.   start)
  47.       # PATH is set above
  48.     log_daemon_msg "Starting $DESC" "$NAME"
  49.     if [ -d /proc/1/. ]
  50.     then
  51.         umask 027
  52.         start-stop-daemon --start --quiet --exec $DAEMON -- \
  53.             $BOOTLOGD_OPTS
  54.         ES=$?
  55.     else
  56.         $DAEMON $BOOTLOGD_OPTS
  57.         ES=$?
  58.     fi
  59.     log_end_msg $ES
  60.     ;;
  61.   stop)
  62.     PATH=/bin:/sbin:/usr/bin:/usr/sbin
  63.     log_daemon_msg "Stopping $DESC" "$NAME"
  64.     start-stop-daemon --oknodo --stop --quiet --exec $DAEMON
  65.     ES=$?
  66.     sleep 1
  67.     log_end_msg $ES
  68.     if [ -f /var/log/boot ] && [ -f /var/log/boot~ ]
  69.     then
  70.         [ "$VERBOSE" = no ] || log_action_begin_msg "Moving boot log file"
  71.         # bootlogd writes to boot, making backup at boot~
  72.         cd /var/log && {
  73.             chgrp adm boot || :
  74.             savelog -q -p -c 5 boot \
  75.             && mv boot.0 boot \
  76.             && mv boot~ boot.0
  77.         }
  78.         ES=$?
  79.         [ "$VERBOSE" = no ] || log_action_end_msg $ES
  80.     fi
  81.     ;;
  82.   restart|force-reload)
  83.      /etc/init.d/bootlogd stop
  84.      /etc/init.d/bootlogd start
  85.     ;;
  86.   status)
  87.     status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  88.     ;;
  89.   *)
  90.     echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
  91.     exit 3
  92.     ;;
  93. esac
  94.  
  95. :
  96.